$(document).ready(function() {
	$('#fullpage').fullpage({
		sectionsColor: ['#5bc0de', '#5cb85c', '#d9534f', '#fff', '#777'],
		anchors: ['library', 'communicate', 'audio-books', 'about-us', 'lastPage'],
		menu: '#menu',
		afterLoad: function(anchorLink, index){
			//section 1
			if(index == 1){
				//moving the image

			    $("#books-number").animate({count: 4000}, {  
			        duration: 1000,  
			        step: function() {  
			            $("#books-number").text(String(parseInt(this.count)));  
			        }  
			    });

			    $("#borrow-number").animate({count: 10000}, {  
			        duration: 1000,  
			        step: function() {  
			            $("#borrow-number").text(String(parseInt(this.count)));  
			        }  
			    });

			    $("#comment-number").animate({count: 500}, {  
			        duration: 1000,  
			        step: function() {  
			            $("#comment-number").text(String(parseInt(this.count)));  
			        }  
			    }); 

			}

			//section 2
			if(index == 2){
				//moving the image
				$('#communicate-section').find('img').delay(500).animate({
					left: '0%'
				}, 1500, 'easeOutExpo');

				$('#communicate-section').find('p').first().fadeIn(1800, function(){
					$('#communicate-section').find('p').last().fadeIn(1800);
				});

			}

			//section 3
			if(anchorLink == 'audio-books'){
				//moving the image
				$('#audio-books-section').find('.intro').delay(500).animate({
					left: '0%'
				}, 1500, 'easeOutExpo');

				$("#audio-number").animate({count: 500}, {  
			        duration: 1000,  
			        step: function() {  
			            $("#audio-number").text(String(parseInt(this.count)));  
			        }  
			    }); 
			}

			//section 4
			if(index == 4){
				//moving the image
				$('#about-us-section').find('img').delay(500).animate({
					left: '0%'
				}, 1500, 'easeOutExpo');

				$('#about-us-section').find('p').first().fadeIn(1800, function(){
					$('#about-us').find('p').last().fadeIn(1800);
				});;

			}

			//section 5
			// if(anchorLink == 'lastPage'){
			// 	//moving the image
			// 	$('#section4').find('.intro').delay(500).animate({
			// 		left: '0%'
			// 	}, 1500, 'easeOutExpo');
			// }
		}
	});

	$("#logout-btn").click(function(e){
		logOut();
	});
});